package cn.controller;

import cn.config.SmsConfig;
import com.zhenzi.sms.ZhenziSmsClient;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.aspectj.bridge.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.SimpleTimeZone;

@Component
public class KafkaController {
    @Autowired
    SmsConfig smsConfig;
     @KafkaListener(topics = "first")
    public  void first(ConsumerRecord<String,String>record, Acknowledgment ack){
         String value = record.value().toString();

         System.err.println(value);

         ack.acknowledge();
         HashMap<String, Object> map = new HashMap<>();
         map.put("number","18171943614");
         map.put("messageId","11459");
         String[] str={"请假通过","五分钟"};
         map.put("templateParams",str);

         ZhenziSmsClient client = smsConfig.zhenziSmsClient(map);
                 System.err.println(client);
         System.err.println("发送成功");
     }
}
